package com.gomore.opple.module.incomeandexpense.detailactivity;

import android.widget.TextView;

import com.gomore.opple.R;
import com.gomore.opple.common.GlobalConstant;
import com.gomore.opple.module.BaseActivity;
import com.gomore.opple.module.IntentStart;
import com.gomore.opple.rest.applybill.ApplyHist;
import com.gomore.opple.utils.BigDecimalUtils;
import com.gomore.opple.utils.DateUtil;

import java.math.BigDecimal;

import butterknife.Bind;

/**
 * Created by asus on 2017/5/26.
 */
public class IncomeAndExpenseDetailActivity extends BaseActivity {
    @Bind(R.id.account)
    TextView account;
    @Bind(R.id.type)
    TextView type;
    @Bind(R.id.in_or_out)
    TextView in_or_out;
    @Bind(R.id.time)
    TextView time;
    @Bind(R.id.bill_number)
    TextView bill_number;
    @Bind(R.id.remain_account)
    TextView remain_account;
    private ApplyHist applyHist;

    @Override
    protected void initalizeViewData() {
        super.initalizeViewData();
        if (getIntent() != null && getIntent().getSerializableExtra(IntentStart.APPLYHIST) != null) {
            applyHist = (ApplyHist) getIntent().getSerializableExtra(IntentStart.APPLYHIST);
        }
    }

    @Override
    protected void initalizeViews() {
        if (applyHist == null) {
            return;
        }
        if (applyHist.getType() != null) {
            type.setText(GlobalConstant.applyType.getNameByType(applyHist.getType()));
        }
        if (applyHist.getAmount() != null) {
            int compare = applyHist.getAmount().compareTo(new BigDecimal(0));
            if (compare == 1) {
                in_or_out.setText("返佣");
            } else {
                in_or_out.setText("提现");
            }
            account.setText(BigDecimalUtils.forMate(applyHist.getAmount()).toString());
        }
        if (applyHist.getCreateDate() != null) {
            time.setText(DateUtil.fomatforDate(applyHist.getCreateDate(), DateUtil.DATE_FORMATTER_1));
        }
        if (applyHist.getBillNumber() != null) {
            bill_number.setText(applyHist.getBillNumber());
        }
        if (applyHist.getRemainAmount() != null) {
            remain_account.setText(BigDecimalUtils.forMate(applyHist.getRemainAmount()).toString());
        }
    }

    @Override
    protected void initializeDependencyInjector() {

    }

    @Override
    protected int getLayoutView() {
        return R.layout.activity_income_and_expense_detail;
    }
}
